package Demo;

import java.util.Scanner;

//软件测试
public class MyDemo {
    public static void main(String[] args) {
        System.out.println("请输入投币金额");
        Scanner scanner = new Scanner(System.in);
        Double money = 0.0;
        String fruit_juice = "";
        while (scanner.hasNext()){
            System.out.println("自动售货机有以下饮品：橙汁 啤酒");
            money = scanner.nextDouble();
            System.out.println("请输入你要买的饮品");
            fruit_juice  = scanner.next();
            if( money == 0.5){
                if(fruit_juice.equals("橙汁")){
                    System.out.println("本次找零:"+ (money-0.5) +"元" + "  成功购买:" + fruit_juice );
                }else if (fruit_juice.equals("啤酒")){
                    System.out.println("本次找零:"+ (money-0.5) +"元" + "  成功购买:" + fruit_juice );
                }else {
                    System.out.println("请重新选择饮料,退回"+ money +"元");
                }
            }else if(money == 1.0){
                if(fruit_juice.equals("橙汁")){
                    System.out.println("本次找零:"+ (money-0.5) +"元" + "  成功购买:" + fruit_juice );
                }else if (fruit_juice.equals("啤酒")){
                    System.out.println("本次找零:"+ (money-0.5) +"元" + "  成功购买:" + fruit_juice );
                }else {
                    System.out.println("请重新选择饮料,退回"+ money +"元");
                }
            }else {
                System.out.println("请投币0.5元或1.0元,退回" + money + "元");
            }
        }
    }
}
